﻿using UnityEngine;
using System.Collections;

public class ButtonPressBehaviour : MonoBehaviour {
	public string currentButton;

	void Update () {
		if(Input.GetKeyDown(KeyCode.E)) {
			RaycastHit hit;
			if(Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, 1.5f)) {
				Debug.Log(hit.transform.tag);
				if(hit.transform.tag == "Button1") {
					Debug.Log("Current:" + currentButton);
					currentButton = hit.transform.gameObject.GetComponent<IngameButtonAction>().Action(currentButton);
					Debug.Log("NewCurrent:" + currentButton);
					/*switch(hit.transform.parent.name) {
						case "BridgeButton":
							if(currentButton != "BridgeButton")
								return;
							//currentButton = Button.GravityButton;
							GameObject.Find("Bridge").GetComponent<Animation>().Play();
							Light.GetLights(LightType.Spot, 0)[1].intensity = 0;
							break;

						case "GravityButton":
							if(currentButton != Button.GravityButton)
								return;
							currentButton = Button.none;
							player.GetComponent<ChangeGravity>().startRotation(level.transform.right, true);
							Light.GetLights(LightType.Spot, 0)[0].intensity = 5;
							player.GetComponent<ResetPlayerPosition>().setStart(2);
							break;

						case "Wall":
							if(currentButton != Button.WallButton)
								return;
							currentButton = Button.BridgeButton;
							GameObject wall = GameObject.Find("Wall");
							wall.GetComponent<Animation>().Play();
							wall.GetComponent<AudioSource>().Play();
							GameObject.Find("ButtonCover1").GetComponent<Animation>().Play();
							GameObject.Find("BridgeButton").GetComponent<Animation>().Play();
							break;
					}*/
				}
			}
		}
	}
}
